//
//  ViewController.m
//  NavBar
//
//  Created by zhangyi on 15/12/15.
//  Copyright © 2015年 zhangyi. All rights reserved.
//

#import "ViewController.h"
#import "NavTabBarController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.edgesForExtendedLayout = UIRectEdgeNone;
    NSArray *data = @[
                      @{
                        @"title":@"新闻",
                        @"color":[UIColor brownColor]
                        },
                      @{
                          @"title":@"体育",
                          @"color":[UIColor purpleColor]
                          },
                      @{
                          @"title":@"娱乐八卦",
                          @"color":[UIColor orangeColor]
                          },
                      @{
                          @"title":@"本地新闻",
                          @"color":[UIColor magentaColor]
                          },
                      @{
                          @"title":@"旅游",
                          @"color":[UIColor yellowColor]
                          },
                      @{
                          @"title":@"军事",
                          @"color":[UIColor cyanColor]
                          },
                      @{
                          @"title":@"国际",
                          @"color":[UIColor blueColor]
                          },
                      @{
                          @"title":@"科技",
                          @"color":[UIColor greenColor]
                          }
                    ];

    NSMutableArray *controllers = [[NSMutableArray alloc] initWithCapacity:data.count];
    for (NSDictionary *d in data) {
        UIViewController *controller = [[UIViewController alloc] init];
        controller.title = d[@"title"];
        controller.view.backgroundColor = d[@"color"];
        [controllers addObject:controller];
    }
    
    NavTabBarController *navTabBarController = [[NavTabBarController alloc] init];
    navTabBarController.subControllers = [controllers copy];
    [self addChildViewController:navTabBarController];
    [self.view addSubview:navTabBarController.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
